﻿<cfcomponent>
<cfscript>
DB = 'chinalaohu';
domain = 'http://img1.chinalaohu.com';
function astagfunc(tag,pt,ot,ct){
	switch(tag){
		case 0:
			return '待审';
			break;
		case 1:
			if (not isdefined('ct')){
				return '通过';
			}
			else {
				if (ct lte now()){
					return '2';
				}
				else if (ot lte now()){
					return '1';
				}
				else if (pt lte now()){
					return '0';
				}
				else if (pt gt now()){
					return '-1';
				}
			}
			break;
		default:
			return '不明';
			break;
	}
}

</cfscript>
<cfparam name="UUID" default="0" type="string" >
<cfparam name="platform" default="0" >

<cffunction name="bidmenu" access="remote" returnFormat="json">
  <cfscript>
	j = {"success":"0"};
	</cfscript>
	<!---根据UUID查找ID--->
  <cfinvoke component="app.cfc.user" method="uuidgetuid" returnvariable="uuidgetuid" uuid="#uuid#">
  <cfif uuidgetuid.recordcount eq 0>
  	<!---,"msg":"用户ID错误"--->
    <cfset j = {"success":"0","errCode":"0"}>
  <cfelse>

  <!---竞拍中--->
  <cfinvoke component="app.cfc.userlastbid" method="userbuyerbidrecord" returnvariable="userbuyerbidrecord" uid="#uuidgetuid.uid#"/>
  <!---已得标--->
  <cfinvoke component="app.cfc.userlastbid" method="userbuyerwonrecord" returnvariable="userbuyerwonrecord" uid="#uuidgetuid.uid#"/>
  <!---未得标--->
  <cfinvoke component="app.cfc.userlastbid" method="userbuyerdontwinrecord" returnvariable="userbuyerdontwinrecord" uid="#uuidgetuid.uid#"/>
  <!---已支付--->
  <cfinvoke component="app.cfc.userwonpaid" method="userpaidrecord" returnvariable="userpaidrecord" uid="#uuidgetuid.uid#"/>
  <!---未支付--->
  <cfinvoke component="app.cfc.userlastbid" method="userunintopaidrecord" returnvariable="userunintopaidrecord" uid="#uuidgetuid.uid#"/>
  
  <!---未支付的订单，关闭功能--->
  <!---
  <cfinvoke component="app.cfc.userwonpaid" method="userunpaidrecord" returnvariable="userunpaidrecord" uid="#uuidgetuid.uid#"/>
  --->
  <!---已发货--->
  <cfinvoke component="app.cfc.userwonpaid" method="sendOutrecord" returnvariable="sendOutrecord" uid="#uuidgetuid.uid#"/>
  <!---未发货--->
  <cfinvoke component="app.cfc.userwonpaid" method="unfilledrecord" returnvariable="unfilledrecord" uid="#uuidgetuid.uid#"/>
  
  
  <cfscript>
j = {
"success":"1",
"auction":{
	"auctioning":userbuyerbidrecord,
	"acquired":userbuyerwonrecord,
	"unpriced":userbuyerdontwinrecord,
	"prepaid":userpaidrecord,
	"nonPayment":userunintopaidrecord,
	"sendOut":sendOutrecord,
	"unfilled":unfilledrecord
}
};
	</cfscript>

	</cfif>
  <cfscript>
	j = createObject("component",'cfjson').encode(j);
  return j;
	</cfscript>
</cffunction>




<!---拍品列表接口--->
<cffunction name="list" access="remote" returnFormat="json">
	<cfparam name="page" default="0">
  <cfparam name="attention" default="">
  <cfscript>
	j = {"success":"0"};
	list = arraynew(1);
	count = 0;
	startrow = page * 20 + 1;
	</cfscript>
	<!---根据UUID查找ID--->
  <cfinvoke component="app.cfc.user" method="uuidgetuid" returnvariable="uuidgetuid" UUID="#uuid#"/>
  <cfif uuidgetuid.recordcount neq 1>
  	<!---,"msg":"用户ID错误"--->
    <cfset j = {"success":"0","errCode":"0"}>
  <cfelse>
  	<!---关注例表--->
    <cfinvoke component="app.cfc.userconcern" method="mygzlist" returnvariable="mygzlist" uid="#uuidgetuid.uid#"/>
    <cfparam name="type" default="">

    <cfswitch expression="#type#">
      <cfcase value="0">
        <!---竞拍中--->
        <cfinvoke component="app.cfc.userlastbid" method="userbuyerbid" returnvariable="userbuyerlist" uid="#uuidgetuid.uid#" mygzlist="#mygzlist#" attention="#attention#"/> 
      </cfcase>
      <cfcase value="1">
        <!---已得标--->
        <cfinvoke component="app.cfc.userlastbid" method="userwon" returnvariable="userbuyerlist" uid="#uuidgetuid.uid#" mygzlist="#mygzlist#" attention="#attention#"/> 
      </cfcase>
      <cfcase value="2">
        <!---未得标--->
        <cfinvoke component="app.cfc.userlastbid" method="userdontwin" returnvariable="userbuyerlist" uid="#uuidgetuid.uid#" mygzlist="#mygzlist#" attention="#attention#"/> 
      </cfcase>
      <cfcase value="3">
        <!---已支付--->
        <cfinvoke component="app.cfc.userwon" method="paidauctionlist" returnvariable="userbuyerlist" uid="#uuidgetuid.uid#" mygzlist="#mygzlist#" attention="#attention#"/> 
      </cfcase>
      <cfcase value="4">
        <!---未支付--->
        <cfinvoke component="app.cfc.userlastbid" method="userwonunpay" returnvariable="userbuyerlist" uid="#uuidgetuid.uid#" mygzlist="#mygzlist#" attention="#attention#"/>
      </cfcase>
      
      <cfcase value="5">
        <!---已发货--->
        <cfinvoke component="app.cfc.userwon" method="shipallwonlist12" returnvariable="userbuyerlist" uid="#uuidgetuid.uid#" mygzlist="#mygzlist#" attention="#attention#"/> 
      </cfcase>
      <cfcase value="6">
        <!---未发货--->
        <cfinvoke component="app.cfc.userwon" method="shipallwonlist03" returnvariable="userbuyerlist" uid="#uuidgetuid.uid#" mygzlist="#mygzlist#" attention="#attention#"/> 
      </cfcase>
      
      <cfdefaultcase>
        <!---关注--->
        <cfinvoke component="app.cfc.userconcern" method="gzlist" returnvariable="userbuyerlist" uid="#uuidgetuid.uid#" mygzlist="#mygzlist#" attention="#attention#"/> 
      </cfdefaultcase>




      <cfcase value="9">
        <!---订单中的未支付--->
        <cfinvoke component="app.cfc.userwon" method="unpaidauctionlist" returnvariable="userbuyerlist" uid="#uuidgetuid.uid#"/>
      </cfcase>
      <cfcase value="8">
        <!---物流--->
        <cfinvoke component="app.cfc.userwon" method="shipallwonlist" returnvariable="userbuyerlist" uid="#uuidgetuid.uid#"/>
      </cfcase>
      
    </cfswitch>
    
    
    
    
    
    
    <cfset count = userbuyerlist.recordcount>
    
    <cfif count gt 0>
    <cfoutput query="userbuyerlist" startrow="#startrow#" maxrows="20">
    <cfscript>
    if (listfind(mygzlist,aid) gt 0){
      attention = 1;
    }
    else {
      attention = 0;
    }
    
switch(platform){
case 0:
  iconUrl = domain & img_waterfall;
  if (left(img_waterfall,8) eq '/upload/' and left(img_waterfall,13) neq '/upload/adio/'){
    iconUrl = domain & replacenocase(img_waterfall,'/upload/','/upload/adio/');
  }
  break;
case 1:
  iconUrl = domain & img_waterfall;
  if (left(img_waterfall,8) eq '/upload/' and left(img_waterfall,12) neq '/upload/ios/'){
    iconUrl = domain & replacenocase(img_waterfall,'/upload/','/upload/ios/');
  }
  break;
}
    
    switch(type){
      
      case 0:
        listjson = {
          "aID":aid,
          "auctionCode":acode,
          "iconUrl": iconUrl,
          "name":auction,
          "lastTime":datetimeformat(endtime,'yyyy-mm-dd HH:NN:SS'),
          "price":lastprice, 
          "attention":attention,
          "auctionType":astagfunc(atag,prevtime,starttime,endtime)
        };
        break;
        
      case 1:
        listjson = {
          "aID":aid,
          "auctionCode":acode,
          "iconUrl": iconUrl,
          "name":auction,
          "dealTime":datetimeformat(endtime,'yyyy-mm-dd HH:NN:SS'),
          "price":lastprice, 
          "attention":attention,
          "auctionType":astagfunc(atag,prevtime,starttime,endtime)
        };
        break;
    
      case 2:
        listjson = {
          "aID":aid,
          "auctionCode":acode,
          "iconUrl": iconUrl,
          "name":auction,
          "dealTime":datetimeformat(endtime,'yyyy-mm-dd HH:NN:SS'),
          "price":lastprice, 
          "attention":attention,
          "auctionType":astagfunc(atag,prevtime,starttime,endtime)
        };
        break;
    
      case 3:
        listjson = {
          "aID":aid,
          "auctionCode":acode,
          "iconUrl": iconUrl,
          "name":auction,
          "dealTime":datetimeformat(endtime,'yyyy-mm-dd HH:NN:SS'),
          "price":lastprice, 
          "attention":attention,
          "auctionType":astagfunc(atag,prevtime,starttime,endtime)
        };
        break;
    
      case 4:
        listjson = {
          "aID":aid,
          "auctionCode":acode,
          "iconUrl": iconUrl,
          "name":auction,
          "dealTime":datetimeformat(endtime,'yyyy-mm-dd HH:NN:SS'),
          "price":lastprice, 
          "attention":attention,
          "auctionType":2
        };
        break;
        
      case 5:
        listjson = {
          "aID":aid,
          "auctionCode":acode,
          "iconUrl": iconUrl,
          "name":auction,
          "dealTime":datetimeformat(endtime,'yyyy-mm-dd HH:NN:SS'),
          "price":bid_amount, 
          "attention":attention,
          "auctionType":2
        };
        break;	
                
      case 6:
        listjson = {
          "aID":aid,
          "auctionCode":acode,
          "iconUrl": iconUrl,
          "name":auction,
          "dealTime":datetimeformat(endtime,'yyyy-mm-dd HH:NN:SS'),
          "price":bid_amount, 
          "attention":attention,
          "auctionType":2
        };
        break;					

      default:
        listjson = {
          "aID":aid,
          "auctionCode":acode,
          "iconUrl": iconUrl,
          "name":auction,
          "preSTime":datetimeformat(prevtime,'yyyy-mm-dd HH:NN:SS'),
          "preETime":datetimeformat(starttime,'yyyy-mm-dd HH:NN:SS'),
          "lastTime":datetimeformat(endtime,'yyyy-mm-dd HH:NN:SS'),
          "dealTime":datetimeformat(endtime,'yyyy-mm-dd HH:NN:SS'),
          "price":lastprice, 
          "attention":attention,
          "auctionType":astagfunc(atag,prevtime,starttime,endtime)
        };
        break;
    }




arrayappend(list,listjson);
    </cfscript>
    </cfoutput>
    <cfscript>
		j = {"success":"1","count":count,"serverTime":datetimeformat(now(),'yyyy-mm-dd HH:NN:SS'),"list":list};
		</cfscript>
		<cfelse>
    <cfscript>
		j = {"success":"1","count":0,"serverTime":datetimeformat(now(),'yyyy-mm-dd HH:NN:SS'),"list":[]};
		</cfscript>
    
    </cfif>
    
      
      
  <!---<cfelse>
			<cfscript>
      j = {"success":"0","msg":"缺少参数"};
      </cfscript>--->

	</cfif>
  
  <cfscript>
	
	j = createObject("component",'cfjson').encode(j);
  return j;
	</cfscript>

</cffunction>

</cfcomponent>